<!DOCTYPE html>
<!--
  Copyright 2016 Google Inc.

  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:

  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  THE SOFTWARE.
-->
<html>
  <head>
    <meta charset="utf-8">
    <title>Select Menu - Material Components Catalog</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="icon" type="image/png" href="/images/logo_components_color_2x_web_48dp.png">
    <link rel="stylesheet" href="/assets/select.css">
    <script src="/ready.js"></script>
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto+Mono">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500">
    <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
    <style>
      #demo-wrapper {
        padding: 4px;
        padding-left: 0;
      }

      .example {
        max-width: 400px;
        margin: 24px;
        padding: 24px;
      }
    </style>
  </head>
  <body class="mdc-typography">
    <header class="mdc-toolbar mdc-toolbar--fixed">
      <div class="mdc-toolbar__row">
        <section class="mdc-toolbar__section mdc-toolbar__section--align-start">
          <a href="/" class="catalog-back mdc-toolbar__menu-icon"><i class="material-icons">&#xE5C4;</i></a>
          <span class="mdc-toolbar__title catalog-title">Select</span>
        </section>
      </div>
    </header>

    <main>
      <div class="mdc-toolbar-fixed-adjust"></div>
      <section class="hero">
        <div id="hero-js-select" class="mdc-select">
          <select class="mdc-select__native-control" id="my-select">
            <option value="grains" selected>
              Bread, Cereal, Rice, and Pasta
            </option>
            <option value="vegetables" disabled>
              Vegetables
            </option>
            <option value="fruit">
              Fruit
            </option>
            <option value="dairy">
              Milk, Yogurt, and Cheese
            </option>
            <option value="meat">
              Meat, Poultry, Fish, Dry Beans, Eggs, and Nuts
            </option>
            <option value="fats">
              Fats, Oils, and Sweets
            </option>
          </select>
          <label class="mdc-floating-label mdc-floating-label--float-above" for="my-select">Pick a Food Group</label>
          <div class="mdc-line-ripple"></div>
        </div>
      </section>

      <section class="example">
        <h2 class="mdc-typography--headline6">Fully-Featured JS Component</h2>
        <section id="demo-wrapper">
          <div id="js-select" class="mdc-select">
            <select class="mdc-select__native-control" id="full-func-js-select">
              <option value="" disabled selected>
              </option>
              <option value="grains">
                Bread, Cereal, Rice, and Pasta
              </option>
              <option value="vegetables" disabled>
                Vegetables
             </option>
              <option value="fruit">
                Fruit
              </option>
              <option value="dairy">
                Milk, Yogurt, and Cheese
              </option>
              <option value="meat">
                Meat, Poultry, Fish, Dry Beans, Eggs, and Nuts
              </option>
              <option value="fats">
                Fats, Oils, and Sweets
              </option>
            </select>
            <label class="mdc-floating-label" for="full-func-js-select">Food Group</label>
            <div class="mdc-line-ripple"></div>
          </div>
        </section>
        <p>Currently selected: <span id="currently-selected">(none)</span></p>
        <div>
          <input type="checkbox" id="rtl">
          <label for="rtl">RTL</label>
        </div>
        <div>
          <input type="checkbox" id="alternate-colors">
          <label for="alternate-colors">Alternate Colors</label>
        </div>
        <div>
          <input type="checkbox" id="disabled">
          <label for="disabled">Disabled</label>
        </div>
        <div class="button-container">
          <button class="mdc-button mdc-button--raised" id="set-selected-index-zero-button">
            Set Selected Index (0)
          </button>
        </div>
        <div class="button-container">
          <button class="mdc-button mdc-button--raised" id="set-value-meat-button">
            Set Value to Meat
          </button>
        </div>
      </section>

      <section class="example">
        <h2 class="mdc-typography--headline6">Outlined Select</h2>
        <section>
          <div id="outline-js-select" class="mdc-select mdc-select--outlined">
            <select class="mdc-select__native-control" id="outlined-select">
              <option value="" disabled selected>
              </option>
              <option value="grains">
                Bread, Cereal, Rice, and Pasta
              </option>
              <option value="vegetables" disabled>
                Vegetables
              </option>
              <option value="fruit">
                Fruit
              </option>
              <option value="dairy">
                Milk, Yogurt, and Cheese
              </option>
              <option value="meat">
                Meat, Poultry, Fish, Dry Beans, Eggs, and Nuts
              </option>
              <option value="fats">
                Fats, Oils, and Sweets
              </option>
            </select>
            <label class="mdc-floating-label" for="outlined-select">Food Group</label>
             <div class="mdc-notched-outline">
               <svg>
                 <path class="mdc-notched-outline__path"></path>
               </svg>
             </div>
             <div class="mdc-notched-outline__idle"></div>
          </div>
        </section>
        <p>Currently selected: <span id="currently-selected-outline">(none)</span></p>
        <div>
          <input type="checkbox" id="rtl-outline">
          <label for="rtl-outline">RTL</label>
        </div>
        <div>
          <input type="checkbox" id="alternate-colors-outline">
          <label for="alternate-colors-outline">Alternate Colors</label>
        </div>
        <div>
          <input type="checkbox" id="disabled-outline">
          <label for="disabled-outline">Disabled</label>
        </div>
        <div class="button-container">
          <button class="mdc-button mdc-button--raised" id="set-selected-index-zero-button-outline">
            Set Selected Index (0)
          </button>
        </div>
        <div class="button-container">
          <button class="mdc-button mdc-button--raised" id="set-value-meat-button-outline">
            Set Value to Meat
          </button>
        </div>
      </section>

      <section class="example">
        <h2 class="mdc-typography--headline6">Pre-selected option via HTML</h2>
        <section>
          <div id="js-pre-selected" class="mdc-select">
            <select class="mdc-select__native-control" id="select-preselected">
              <option value="fruit-roll-ups" selected>
                Fruit Roll Ups
              </option>
              <option value="cotton-candy">
                Candy (cotton)
              </option>
              <option value="vegetables" disabled>
                Vegetables
              </option>
              <option value="noodles">
                Noodles
              </option>
            </select>
            <label class="mdc-floating-label mdc-floating-label--float-above" for="select-preselected">Food Group</label>
            <div class="mdc-line-ripple"></div>
          </div>
        </section>
      </section>
      <section class="example">
        <h2 class="mdc-typography--headline6">MDC Select with optgroups</h2>
        <div id="optgroup-js-select" class="mdc-select">
          <select class="mdc-select__native-control" id="select-optgroups">
            <optgroup label="Meats">
              <option value="steak">Steak</option>
              <option value="hamburger">Hamburger</option>
            </optgroup>
            <optgroup label="Vegetables">
              <option value="beet">Beet</option>
              <option value="carrot">Carrot</option>
            </optgroup>
          </select>
          <label class="mdc-floating-label" for="select-optgroups">Choose Food</label>
          <div class="mdc-line-ripple"></div>
        </div>
      </section>
    </main>

    <script src="/assets/material-components-web.js" async></script>
    <script>
      demoReady(function() {
        mdc.select.MDCSelect.attachTo(document.getElementById('hero-js-select'));
        mdc.select.MDCSelect.attachTo(document.getElementById('js-pre-selected'));
        mdc.select.MDCSelect.attachTo(document.getElementById('optgroup-js-select'));

        var root = document.getElementById('js-select');
        var currentlySelected = document.getElementById('currently-selected');
        var select = new mdc.select.MDCSelect(root);
        var demoWrapper = document.getElementById('demo-wrapper');
        var rtlCb = document.getElementById('rtl');
        var alternateColorsCb = document.getElementById('alternate-colors');
        var disabledCb = document.getElementById('disabled');
        var setSelectedButton = document.getElementById('set-selected-index-zero-button');
        var setValueMeatButton = document.getElementById('set-value-meat-button');
        function updateSelectedTextContent() {
          var value = select.value;
          var index = select.selectedIndex;
          currentlySelected.textContent = value ? value + ' at index ' + index : '(none)';
        }
        root.addEventListener('change', function() {
          updateSelectedTextContent();
        });
        rtlCb.addEventListener('change', function() {
          if (rtlCb.checked) {
            demoWrapper.setAttribute('dir', 'rtl');
          } else {
            demoWrapper.removeAttribute('dir');
          }
        });
        alternateColorsCb.addEventListener('change', function() {
          root.classList[alternateColorsCb.checked ? 'add' : 'remove']('demo-select-custom-colors');
        });
        disabledCb.addEventListener('change', function() {
          select.disabled = disabledCb.checked;
        });
        setSelectedButton.addEventListener('click', function() {
          select.selectedIndex = 0;
          updateSelectedTextContent();
        });
        setValueMeatButton.addEventListener('click', function() {
          select.value = 'meat';
          updateSelectedTextContent();
        });
      });

      demoReady(function() {

        var root = document.getElementById('outline-js-select');
        var currentlySelected = document.getElementById('currently-selected-outline');
        var select = new mdc.select.MDCSelect(root);
        var demoWrapper = root.parentElement;
        var rtlCb = document.getElementById('rtl-outline');
        var alternateColorsCb = document.getElementById('alternate-colors-outline');
        var disabledCb = document.getElementById('disabled-outline');
        var setSelectedButton = document.getElementById('set-selected-index-zero-button-outline');
        var setValueMeatButton = document.getElementById('set-value-meat-button-outline');
        function updateSelectedTextContent() {
          var value = select.value;
          var index = select.selectedIndex;
          currentlySelected.textContent = value ? value + ' at index ' + index : '(none)';
        }
        root.addEventListener('change', function() {
          updateSelectedTextContent();
        });
        rtlCb.addEventListener('change', function() {
          if (rtlCb.checked) {
            demoWrapper.setAttribute('dir', 'rtl');
          } else {
            demoWrapper.removeAttribute('dir');
          }
          select.layout();
        });
        alternateColorsCb.addEventListener('change', function() {
          root.classList[alternateColorsCb.checked ? 'add' : 'remove']('demo-select-custom-colors');
        });
        disabledCb.addEventListener('change', function() {
          select.disabled = disabledCb.checked;
        });
        setSelectedButton.addEventListener('click', function() {
          select.selectedIndex = 0;
          updateSelectedTextContent();
        });
        setValueMeatButton.addEventListener('click', function() {
          select.value = 'meat';
          updateSelectedTextContent();
        });
      });
    </script>
  </body>
</html>
